$(function() {

    $( "#tabs" ).tabs().tabs("rotate", 4000);
    $( ".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *" )
	.removeClass( "ui-corner-all ui-corner-top" )
	.addClass( "ui-corner-bottom" );
    $('#entrar').button({ icons:{ primary:"ui-icon-home" } });            
    $('#tabs-1').sbscroller();

    ///////////////////////
    // Invocando a qTip2 //
    ///////////////////////
    hps = new Array();
    count = 0;
    $('a', "#wrapper").each(function() {
        hps[count] = $(this).attr("id");
        count++;
    });
    string = hps[0];
    for (var i = 1; i < hps.length; i++) {
        string = string + ":" + hps[i];
    }
    $.ajax({
	type: 'post',
        dataType: 'json',
	async:false,
        url: 'login/getTooltip',
        data: {"element":string},
	success:  function(response){			  
            return tooltips=response;        
        }
    });




    $('a', "#wrapper").each(function() {
        contentt = undefined;
        if($(this).attr("id") !== undefined){
            element = $(this).attr("id");
            $.each(tooltips, function(property, value) {
                if(property !== "undefined"){
                    if (property  ===  element)
                        contentt = value;
                }
            });
        }
        
        contentt = (contentt === undefined) ? "Tooltip no asignado" : contentt;
	$(this).qtip({
	    content: contentt,
	    position: {
		/*
		 * We'll stick the tooltip within the tab content div, so that if we change
		 * tabs, the tooltip will be hidden along with the rest of the tab contents
		 */
		container: $(this).parents('[id^="tabs"]')
	    },
	    style: {
		classes: 'ui-tooltip-shadow',
		widget: true // Blend it in with the Themeroller styles
	    }
	})
    })
});
